package h_eekwan.basic;

import java.util.Scanner;

public class J05_49GreatDivider {

	public static void main(String[] args) {
		//
		Scanner sc = null;
		int a=0;
		int b=0;
		int c=0;
		sc = new Scanner(System.in);
		System.out.println(a);
		a = sc.nextInt();
		System.out.println(b);
		b = sc.nextInt();
		
		while(b!=0){
			System.out.println(a + "와 " + b +"의 최대 공약수는 "+ c +" 입니다.");
			c = b%a;
			a = b;
			
			
			b = c;
		}
		sc.close();

	}

}
